import { sys } from "cc";
import { gm } from "./managers/GameManager";
import { udm } from "./managers/UserDataManager";
import { GameStatus } from "./managers/Enums";

globalThis.dev = {

    clear() {
        udm.clear();
        gm.frontTipShow(`已清理 请重启`).subscribe();
    },

    save(key = '1') {
        let profile0 = sys.localStorage.getItem(udm.localstorageKey);
        sys.localStorage.setItem('profile' + key, profile0);
        gm.frontTipShow(`已保存:${key}`).subscribe();
    },

    load(key = '1') {
        let profile = sys.localStorage.getItem('profile' + key);
        sys.localStorage.setItem(udm.localstorageKey, profile);
        gm.frontTipShow(`已读取:${key} 请重启`).subscribe();
    },

    stagelock() {
        udm.curStage.value = 1;
        udm.save();
    },

    // stageset(stageNum) {
    //     udm.curStage.value = stageNum;
    //     udm.save();
    //     // gm.loadGame({ stageNum: stageNum });
    // },

    // lose() {
    //     gm.gameStatus.value = GameStatus.Lose;
    // },

    // saveStage() {
    //     const stageNum = gm.stageInfo.value.stageNum;
    //     sys.localStorage.setItem('stage' + stageNum, JSON.stringify(gm.curStage.itemData));
    // },

    // loadStage() {
    //     const stageNum = gm.stageInfo.value.stageNum;
    //     const itemData = JSON.parse(sys.localStorage.getItem('stage' + stageNum));
    //     gm.curStage.clearItems();
    //     gm.curStage.generateItems(itemData);
    //     gm.curStage.checkLose();
    // },

    ff(sec: number = 60) {
        gm.curTime.value += sec;
    }

}